<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="../../org/angular.min.js"></script>
</head>

<body ng-app="app" ng-controller="ctrl">
    <table border="1" width="500">
        <tr>
            <th ng-click="orderBy('id')">
                id
                <span ng-if="status.id==true">升序</span>
                <span ng-if="status.id==false">降序</span>
            </th>
            <th ng-click="orderBy('title')">姓名
                <span ng-if="status.title==true">升序</span>
                <span ng-if="status.title==false">降序</span>
            </th>
            <th ng-click="orderBy('age')">年龄
                <span ng-if="status.age==true">升序</span>
                <span ng-if="status.age==false">降序</span>
            </th>
        </tr>
        <tr ng-repeat="v in data">
            <td>{{v.id}}</td>
            <td>{{v.title}}</td>
            <td>{{v.age}}</td>
        </tr>
    </table>
    <script>
        var m = angular.module('app', []);
        m.controller('ctrl', ['$scope', '$filter', function($scope, $filter) {
            $scope.data = [{
                    id: 9,
                    title: 'zyx',
                    age: 19
                },
                {
                    id: 2,
                    title: 'aya',
                    age: 29
                },
                {
                    id: 3,
                    title: 'moon',
                    age: 9
                },
            ];
            $scope.status = {
                id: false,
                title: false,
                age: false
            };
            $scope.orderBy = function(field) {
                $scope.status[field] = !$scope.status[field];
                $scope.data = $filter('orderBy')($scope.data, field, $scope.status[field]);
            }
        }])
    </script>
</body>

</html>
